import entity.BinaryTree;
import entity.TreeNode;

/**
 * @Author: wanqian
 * @Date: 2021/2/4 15:13
 */
public class BinaryTreeDemo {

    public static void main(String[] args) {
        TreeNode jack = new TreeNode(1, "Jack");
        TreeNode Tom = new TreeNode(2, "Tom");
        TreeNode Tony = new TreeNode(3, "Tony");
        TreeNode Kris = new TreeNode(4, "Kris");
        TreeNode Mark = new TreeNode(5, "Mark");
        TreeNode Sheldon = new TreeNode(6, "Sheldon");
        TreeNode Leonard = new TreeNode(7, "Leonard");
        BinaryTree binaryTree = new BinaryTree(jack);
        jack.setLeft(Tom);
        jack.setRight(Tony);
        Tony.setLeft(Kris);
        Tony.setRight(Mark);
//        Tom.setLeft(Sheldon);
//        Tom.setRight(Leonard);

        binaryTree.postOrder();
        System.out.println();
        binaryTree.postThreadedNode();
        binaryTree.postThreadedList();
        /**
         * 遍历
         */
//        System.out.println("前序遍历");
//        binaryTree.preOrder();
//        System.out.println("中序遍历");
//        binaryTree.infixOrder();
//        System.out.println("后序遍历");
//        binaryTree.postOrder();

        /**
         * 查找
         */
//        TreeNode result;
//        System.out.println("前序查找");
//        result = binaryTree.preOrderSearch(4);
//        System.out.println("中序查找");
//        result = binaryTree.infixOrderSearch(6);
//        System.out.println("后序查找");
//        result = binaryTree.postOrderSearch(6);
//        if (result != null) {
//            System.out.println("找到目标节点" + result);
//        } else {
//            System.out.println("未找到目标节点");
//        }

        /**
         * 删除
         */
//        binaryTree.deleteById(2);
//        binaryTree.preOrder();
    }
}
